package ioperations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperations implements IOperations{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入想要归还的书名");
        String name = scanner.nextLine();

        int usedszie = bookList.getUseSize();
        for (int i = 0; i < usedszie; i++) {
            Book book = bookList.getBooks(i);

            if(book.getName().equals(name)) {
                if(book.isBorrowed()) {
                    book.setBorrowed(false);
                    System.out.println("归还成功");
                    return;
                }

            }
        }
        System.out.println("没有找到"+ name +"这本书");
    }
}
